﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using OneSoft.EntityCore;
using OneSoft.DataAccess;
using BySoft.Server.Common.Entity;
using BySoft.Server.Common.Schema;


namespace BySoft.Server.DataAccess 
{
    public partial class SysFormcheckDA
    {
        public static DataTable SelectList(string strCode)
        {
            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                try
                {
                    #region SQL Server
                    DataAccessParameterCollection dpc = new DataAccessParameterCollection();
                    string strcmd = @" SELECT a.*,'采购收料让步审核'   as ModuleName,
 CASE WHEN a.IsCheck='1' THEN '是' ELSE '否' END AS IsCheckName
 FROM SYS_FormCheck a 
 WHERE a.[Status]='1'";
                    if (!string.IsNullOrEmpty(strCode))
                    {
                     
                    }
                    return broker.FillSQLDataSet(strcmd, dpc).Tables[0];
                    #endregion
                }
                catch
                {
                    throw;
                }
            }
        }

        public static DataTable SelectHead(string strCode)
        {
            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                try
                {
                    #region SQL Server
                    DataAccessParameterCollection dpc = new DataAccessParameterCollection();
                    string strcmd = @"  SELECT a.*, b.CheckUser,b.FormCheckDetailID,b.OrderNum,su.UserName,b.IsEnd
 FROM SYS_FormCheck a 
 LEFT JOIN SYS_FormCheckDetail b ON b.FormCheckID=a.FormCheckID
 LEFT JOIN SYS_User su ON su.UserID=b.CheckUser
 WHERE a.[Status]='1' ";
                    if (!string.IsNullOrEmpty(strCode))
                    {
                        strcmd += " AND a.FormCheckID=@strCode";
                        dpc.AddWithValue("@strCode", strCode);
                    }
                    return broker.FillSQLDataSet(strcmd, dpc).Tables[0];
                    #endregion
                }
                catch
                {
                    throw;
                }
            }
        }

    }
}
